<div class="page-content">
    <!-- BEGIN PAGE HEADER-->
	<div class="row">
		<div class="col-md-12">
			<!-- BEGIN PAGE TITLE & BREADCRUMB-->
			<h3 class="page-title">
		          Add Product
			</h3>
			<ul class="page-breadcrumb breadcrumb">
				<li>
					<i class="fa fa-home"></i>
					<a href="<?php echo $this->Admin->admin_url() ?>">
						Home
					</a>
					<i class="fa fa-angle-right"></i>
				</li>
				<li>
					<a href="<?php echo $this->Admin->admin_url() ?>product/index">
						Product list
					</a>
					<i class="fa fa-angle-right"></i>
				</li>
				<li>
					<a href="javascript:void(0)">
						Add Product
					</a>
				</li>
			</ul>
			<!-- END PAGE TITLE & BREADCRUMB-->
		</div>
	</div>
	<!-- END PAGE HEADER-->
	<!-- BEGIN PAGE CONTENT-->
    <div class="row">
        <div class="col-md-12">
        	<!-- BEGIN VALIDATION STATES-->
        	<div class="portlet box blue">
        		<div class="portlet-title">
        			<div class="caption">
        				<i class="fa fa-reorder"></i>Managed_table
        			</div>
        		</div>
        		<div class="portlet-body form">
        			<!-- BEGIN FORM-->
        			<!--form action="" id="form_category" class="form-horizontal" method="post"-->
                    <?php
                        echo $this->Form->create('Product', array(
                                                            'url' => array('controller' => 'product', 'action' => 'add', $parent_id), 
                                                            'type' => 'post',
                                                            'id' => 'form_product',
                                                            'class' => 'form-horizontal'));
                    ?>
                        
        				<div class="form-body">
                            <div class="form-group">
                                <label class="control-label col-md-3" for="type">Type
                                <span class="required">
        							 *
        						</span>
                                </label>
                                <div class="col-md-4 error_category">
            					<?php
                                    $types = array('cutkit' => 'CUT KIT', 'hsth' => 'HOA SI TI HON');
                                    echo $this->Form->select('type', $types, 
                                                            array(
                                                                'class' => 'form-control',
                                                                'id' => 'type',
                                                                'empty' => 'Choice type'
                                                            )
                                    );
                                ?>
                                </div>
            				</div>
                            
                            <div class="form-group">
        						<label class="control-label col-md-3">Category
        						<span class="required">
        							 *
        						</span>
        						</label>
        						<div class="col-md-9 error_list_category">
                                    <div class="form-control height-auto">
										<div class="scroller" style="height:275px;" data-always-visible="1">
											<ul class="list-unstyled list_category">
												<?php
                                                    $option = '';
                                                    foreach($filter_category as $category)
                                                    {
                                                        $level = $category['level'];
                                                        $px = 0;
                                                        for($i = 1; $i <= $level; $i++)
                                                        {
                                                            $px += 30;
                                                        }
                                                        $style = 'style="margin-left:'.$px.'px"';
                                                        $checked = '';
                                                        
                                                        if($parent_id == $category['category_id'])
                                                        {
                                                            $checked = "checked=''";
                                                            $option = '<option selected="selected" value="'.$category['category_id'].'">'.$category['title'].'</option>';
                                                        }
                       
                                                ?>
                                                    <li <?php echo $style ?>>
                                                        <label><input <?php echo $checked ?> type="checkbox" name="product_category[]" value="<?php echo $category['category_id'] ?>" title="<?php echo $category['title'] ?>"/> <?php echo $category['title'] ?></label>
                                                    </li>
                                                
                                                
                                                <?php        
                                                    }
                                                ?>
											</ul>
										</div>
									</div>
        						</div>
        					</div>
                            
                            <div class="form-group">
        						<label class="control-label col-md-3">Main category</label>
        						<div class="col-md-4 error_category">
                                    <select class="form-control select_main_category" name="main_category">
                                        <option value="">Choice main category</option>
                                        <?php echo $option ?>
                                    </select>
                                </div>
        					</div>
                            <div style="display: none;" class="form-group">
                                <label class="control-label col-md-3" for="brand_id">Brand</label>
                                <div class="col-md-4 error_category">
            					<?php
                                    
                                    echo $this->Form->select('brand_id', $list_brands, 
                                                            array(
                                                                'class' => 'form-control',
                                                                'empty' => 'Brands'
                                                            )
                                    );
                                ?>
                                </div>
            				</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Status
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-9">
                                    <div class="radio-list">
										<label>
										<input checked="checked" type="radio" name="status" value="1"/>
										Enable </label>
										<label>
										<input type="radio" name="status" value="0"/>
										Disable </label>
									</div>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Sort order
                                 </label>
        						<div class="col-md-4">
                                    <?php
                                        echo $this->Form->text('sort_order',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control'
                                                        )
                                        );
                                    ?>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Price
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-4">
                                    <?php
                                    /*
                                        echo $this->Form->input('price',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control',
                                                            'type' => 'text'
                                                        )
                                        );
                                    */
                                    ?>
                                    <input type="text" id="price" class="form-control" name="data[Product][price]"/>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Discount
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-4">
                                    <?php
                                    /*
                                        echo $this->Form->input('discount',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control',
                                                            'type' => 'text'
                                                        )
                                        );
                                    */
                                    ?>
                                    <input type="text" id="discount" class="form-control" name="data[Product][discount]"/>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">percent Discount
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-4">
                                    <?php
                                    /*
                                        echo $this->Form->input('percent_discount',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control',
                                                            'type' => 'text'
                                                        )
                                        );
                                    */
                                    ?>
                                    <input type="text" id="percent_discount" class="form-control" name="data[Product][percent_discount]"/>
        						</div>
        					</div>
                            
                            <div class="form-group">
        						<label class="control-label col-md-3">Image&nbsp;&nbsp;</label>
        						<div class="col-md-4">
                                    <div class="btn-group btn-group-xs btn-group-solid">
                                        <img id="main_image" class="show_image_browse" src="<?php echo $this->webroot ?>upload/images/no-image.jpg" />
                                        <input class="main_image" type="hidden" name="main_image" value="<?php echo $this->webroot ?>upload/images/no-image.jpg" />
                                        <div class="clear"></div>
                                        <button class="btn blue fileBrowse" data-target="main_image" type="button">Browse File</button>
										<button class="btn red fileDelete" data-target="main_image" type="button">Delete File</button>
                                    </div>
                                </div>
        					</div>
                            
                            <div class="form-group">
        						<label class="control-label col-md-3">Image other&nbsp;&nbsp;</label>
        						<div class="col-md-8 other_image">
                                    
                                    <div class="btn_add_image">
                                        <img src="<?php echo $this->webroot ?>img/add-image.png" alt="add_image" />
                                    </div>
                                    
                                </div>
        					</div>
                            
                            
    
                            <div class="">
        						<label class="control-label col-md-3"></label>
        						<div class="col-md-9">
                        			<div class="tabbable tabbable-custom">
                        				<ul class="nav nav-tabs">
                                            <?php
                                                $i=0;
                                                foreach($list_language as $language)
                                                {
                                                    $language = $language['language'];
                                                    $lang_code = $language['lang_code'];
                                            ?>
                        					<li class='<?php echo $i++==0 ? "active" : "" ?>'>
                        						<a data-toggle="tab" href="#tab_<?php echo $lang_code ?>">
                        							 <img src="<?php echo $this->webroot; ?>admin/img/flags/<?php echo $lang_code ?>.png" />
                                                     <?php echo $language['title'] ?>
                        						</a>
                        					</li>
                                            <?php
                                                }
                                            ?>
                        				</ul>
                        				<div class="tab-content">
                                            <?php
                                                $i = 0;
                                                foreach($list_language as $language)
                                                {
                                                    $language = $language['language'];
                                                    $lang_code = $language['lang_code'];
                                            ?>
                                            <div id="tab_<?php echo $lang_code ?>" class="tab-pane <?php echo $i++==0 ? "active" : "" ?>">
                                                <div class="form-group">
                            						<label class="control-label mgl15">Title
                                                        <span class="required">*</span>
                            						</label>
                            						<div class="col-md-12 error-title">
                                                        <?php
                                                        echo $this->Form->input('title_'.$lang_code,
                                                                            array(
                                                                                'label' => false,
                                                                                'div' => false,
                                                                                'class' => 'form-control',
                                                                                'id' => 'title_'.$lang_code,
                                                                                'lang_code' => $lang_code
                                                                            )
                                                            );
                                                        ?>
                                                        <!--
                                                        <input type="text" id="title_<?php echo $lang_code ?>" class="form-control" name="data[Product][title_<?php echo $lang_code ?>]"/>
                                                        -->
                                                    </div>
                            					</div>
                                                <div class="form-group">
                            						<label class="control-label mgl15">Link
                                                        <span class="required">*</span>
                            						</label>
                            						<div class="col-md-12">
                                                    <?php
                                                        echo $this->Form->input('link_'.$lang_code,
                                                                        array(
                                                                            'label' => false,
                                                                            'div' => false,
                                                                            'class' => 'form-control',
                                                                            'id' => 'link_'.$lang_code,
                                                                            'lang_code' => $lang_code
                                                                        )
                                                        );
                                                    ?>
                                                    </div>
                            					</div>
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                            						<label class="control-label mgl15">
                                                        Thông tin sản phẩm
                            						</label>
                            						<div class="col-md-12">
                           							      <?php
                                                            echo $this->Form->textarea('description_'.$lang_code, array('class' => 'form-control', 'rows' => '6'));
                                                        ?>
                                                    </div>
                            					</div>
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                            						<label class="control-label mgl15">
                                                        Phát triển kỹ năng
                            						</label>
                            						<div class="col-md-12">
                           							      <?php
                                                            echo $this->Form->textarea('long_description_'.$lang_code, array('class' => 'form-control', 'rows' => '6'));
                                                        ?>
                                                    </div>
                            					</div>
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                            						<label class="control-label mgl15">
                                                        Meta title
                                                    </label>
                            						<div class="col-md-12">
                            							<?php
                                                            echo $this->Form->input('meta_title_'.$lang_code,
                                                                            array(
                                                                                'label' => false,
                                                                                'div' => false,
                                                                                'class' => 'form-control'
                                                                            )
                                                            );
                                                        ?>
                            						</div>
                            					</div>
                                                
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                                                    <label class="control-label mgl15">
                                                        Meta description
                            						</label>
                            						<div class="col-md-12">
                                                        <?php
                                                            echo $this->Form->textarea('meta_description_'.$lang_code, array('class' => 'form-control'));
                                                        ?>
                            						</div>
                                                </div>
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                                                    <label class="control-label mgl15">
                                                        Meta_keywords
                            						</label>
                            						<div class="col-md-12">
                                                        <?php
                                                            echo $this->Form->textarea('meta_keywords_'.$lang_code, array('class' => 'form-control'));
                                                        ?>
                            						</div>
                                                </div>
                                                <!--END_INPUT_FORM-->
                                                <div class="clearfix"></div>
                        					</div>
                        					<!--end tab-pane-->
                                            <?php
                                                }
                                            ?>
                        					<!--end tab-pane-->
                                            <div class="clearfix"></div>
                        				</div>
                                        
                        			</div>
                        		</div>
        					</div>
                            <div class="clearfix"></div>
        				</div>
        				<div class="form-actions fluid">
        					<div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn blue" name="btn_submit" value="ok">Submit</button>
        						<button type="button" class="btn default" onclick="window.location.href='<?php echo $this->Admin->admin_url() ?>product/index/<?php echo $parent_id ?>'">Cancel</button>
        					</div>
        				</div>
                        
        			<?php echo $this->Form->end(); ?>
        			<!-- END FORM-->
        		</div>
        		<!-- END VALIDATION STATES-->
        	</div>
        </div>
    </div>
</div>

                    
                    
<!-- END CONTENT -->

<script type="text/javascript" src="<?php echo $this->webroot; ?>ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>ckfinder/ckfinder.js"></script>

<script>
    <?php
        foreach($list_language as $language)
        {
            $language = $language['language'];
            $lang_code = $language['lang_code'];
    ?>
        var description_<?php echo $lang_code ?> = CKEDITOR.replace('data[Product][description_<?php echo $lang_code ?>]');
        CKFinder.setupCKEditor( description_<?php echo $lang_code ?>, '<?php echo $this->webroot ?>ckfinder/' );
        var long_description_<?php echo $lang_code ?> = CKEDITOR.replace('data[Product][long_description_<?php echo $lang_code ?>]');
        CKFinder.setupCKEditor( long_description_<?php echo $lang_code ?>, '<?php echo $this->webroot ?>ckfinder/' );
    <?php
        }
    ?>
</script>